<?php

namespace app\common\model;

use think\Model;
use traits\model\SoftDelete;

/**
 * 发票模型
 */
class UserReserve extends Model
{
//    use SoftDelete;

    // 开启自动写入时间戳字段
//    protected $autoWriteTimestamp = 'int';
    // 定义时间戳字段名
//    protected $createTime = 'createtime';
//    protected $updateTime = 'updatetime';
//
//    protected $deleteTime = 'deletetime';
    // 追加属性
    protected $append = [

    ];

    /**
     * 预约商品-添加
     * */
    public static function getAdd($goods_id,$user_id,$type=0,$sku_id){
        $data['goods_id']=$goods_id;
        $data['user_id']=$user_id;
        $data['type']=$type;
        $data['sku_id']=$sku_id;

        return self::create($data);
    }
    /**
     * 判断是否预约
     * */
    public static function getInfo($goods_id,$user_id,$type=0){
        $data['goods_id']=$goods_id;
        $data['user_id']=$user_id;
        $data['type']=$type;
        return self::where($data)->find();
    }
    /**
     * 通过规格id，判断是不是预约过
     * */
    public static function getSkuId($suk_id,$goods_id,$user_id){
        $data['sku_id']   = $suk_id;
        $data['goods_id'] = $goods_id;
        $data['user_id'] = $user_id;
        $info = self::where($data)->find();
        if($info){
            $code =1;
        }else{
            $code=0;
        }
        return $code;
    }
}
